package com.dys.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @className: com.dys.controller.PathController
 * @description: SpringMVC @PathVariable注解
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/10/25 22:23
 */
@Controller
public class PathController {

    @RequestMapping(value = {"/testPathVariable/{id}/{username}"})
    public String testPathVariable(@PathVariable(value = "id") Integer id, @PathVariable(value = "username") String username) {
        System.out.println("springmvc PathVariable注解1......");
        System.out.println("id: " + id);
        System.out.println("username: " + username);
        // 需要使用绝对路径,使用相对路径跳转不了
        return "/success";
    }

    @RequestMapping("/testPathVariable2/{id}")
    public String testPathVariable2(@PathVariable(value = "id") String id) {
        System.out.println("springmvc PathVariable注解2......");
        System.out.println("id: " + id);
        // 需要使用绝对路径,使用相对路径跳转不了
        return "/success";
    }

    @RequestMapping("/testPathVariable3")
    public String testPathVariable3() {
        System.out.println("springmvc PathVariable注解3......");
        return "success";
    }
}
